import 'package:flutter/material.dart';
import 'package:kq_flutter_core_widget/utils/kq_screen_util.dart';
import 'package:kq_flutter_widgets/resources/kq_theme_colors.dart';
import 'package:kq_flutter_widgets/widgets/titleBar/kq_title_bar.dart';
import 'package:kq_flutter_widgets_example/router/route_map.dart';

/// 表格演示主界面
class ChartPage extends StatelessWidget {
  const ChartPage({super.key});

  /// 菜单布局
  Widget gridMenuItem(String menuName, GestureTapCallback? onTap) {
    return InkWell(
      onTap: onTap,
      child: Container(
        color: KqThemeColors.bgWhite,
        padding: EdgeInsets.all(10.r),
        child: Text(
          menuName,
          style: TextStyle(
            fontWeight: FontWeight.bold,
            color: Colors.black,
            fontSize: 20.sp,
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: KqHeadBar(
        headTitle: '图表演示',
        showBack: false,
      ),
      body: GridView.count(
        crossAxisCount: 2,
        scrollDirection: Axis.vertical,
        //宽高比
        childAspectRatio: 2 / 1,
        padding: EdgeInsets.all(12.r),
        mainAxisSpacing: 12.r,
        crossAxisSpacing: 12.r,
        children: [
          gridMenuItem('折线图', () {
            RouteMap.goLineChartPage();
          }),
          gridMenuItem('柱状图', () {
            RouteMap.pushBarChartPage();
          }),
          gridMenuItem('饼状图', () {
            RouteMap.pushPieChartPage();
          }),
          gridMenuItem('3D饼状图', () {
            RouteMap.pushPieChart3DPage();
          }),
          gridMenuItem('雷达图', () {
            RouteMap.pushRadarChartPage();
          }),
        ],
      ),
    );
  }
}
